<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>title</title>
</head>
<body>
<div id="app">
<!--    enter键抬起时自动触发-->
    <input type="text" @keyup.enter="search">
    <!--    enter键按下时自动触发-->
    <input type="text" @keydown.enter="search">
    <button @click="search()">点击搜索</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    const app=new Vue({
        el:"#app",
        data:{
        },
        methods:{
            search() {
                alert("共10条结果");
            }
        }
    });
</script>
</body>
</html>